﻿<UserControl x:Class="HeatList"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controlers="clr-namespace:Hinshelwood.TFSHeatITSM.Controlers"
    xmlns:local="clr-namespace:Hinshelwood.TFSHeatITSM"  Background="Transparent" MinWidth="100" MinHeight="100" >
    <UserControl.Resources>
        
        <Style x:Key="CallLogButtonStyle">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=CallLogHasTFSId}" Value="True">
                    <Setter Property="StackPanel.Visibility" Value="Collapsed" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=HasWorkItem}" Value="False">
                    <Setter Property="StackPanel.Visibility" Value="Collapsed" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
        
        
        <DataTemplate x:Key="CallLogTemplate">
            <Border BorderBrush="{DynamicResource BorderBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="4" CornerRadius="5" Margin="6" Height="150">
                <DockPanel>
                    <StackPanel x:Name="uxUpdateCallLog" DockPanel.Dock="Bottom" Style="{DynamicResource CallLogButtonStyle}">
                        <Button Content="Update Call Log" Command="controlers:LinksCommands.UpdateCallLogRefNoWithTFSId" CommandParameter="{Binding}" Width="Auto"  />
                    </StackPanel>
                    <StackPanel MinWidth="100" MaxWidth="300" DataContext="{Binding Path=CallLog}">
                        <TextBlock Text="{Binding Path=CallID}" Foreground="{DynamicResource FontColor}"></TextBlock>
                        <TextBlock Text="{Binding Path=CallType}" Foreground="{DynamicResource FontColor}"></TextBlock>

                        <ScrollViewer Width="Auto" Style="{DynamicResource {x:Static GridView.GridViewScrollViewerStyleKey}}" MaxHeight="100" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
                            <TextBlock Text="{Binding Path=CallDesc}" MaxWidth="300" TextWrapping="Wrap"  Foreground="{DynamicResource FontColor}"></TextBlock>
                        </ScrollViewer>
                    </StackPanel>
                    
                </DockPanel>
            </Border>
        </DataTemplate>
        
        <DataTemplate x:Key="WorkItemTemplate">
            <Border Height="150" BorderBrush="{DynamicResource BorderBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" BorderThickness="4" CornerRadius="5" Margin="6">
                <DockPanel>
                    <StackPanel x:Name="uxCreateWorkItem" DockPanel.Dock="Bottom">
                        <StackPanel.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=HasWorkItem}" Value="True">
                                        <Setter Property="StackPanel.Visibility" Value="Collapsed" />
                                        <Setter Property="StackPanel.Height" Value="0" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Path=HasWorkItem}" Value="False">
                                        <Setter Property="StackPanel.Visibility" Value="Visible" />
                                        <Setter Property="StackPanel.Height" Value="Auto" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </StackPanel.Style>
                        <Button Content="Create Work Item" Command="controlers:LinksCommands.ChangeItemCommand" CommandParameter="{Binding}" Width="Auto" />
                    </StackPanel>
                    <StackPanel MinWidth="100">
                        <StackPanel.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=HasWorkItem}" Value="False">
                                        <Setter Property="StackPanel.Visibility" Value="Collapsed" />
                                        <Setter Property="StackPanel.Height" Value="0" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Path=HasWorkItem}" Value="True">
                                        <Setter Property="StackPanel.Visibility" Value="Visible" />
                                        <Setter Property="StackPanel.Height" Value="Auto" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Path=WorkItemStatus}" Value="Failed">
                                        <Setter Property="StackPanel.Background" Value="Red" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </StackPanel.Style>
                        <TextBlock Text="{Binding Path=WorkItem.Id}" Foreground="{DynamicResource FontColor}"></TextBlock>
                        <TextBlock Text="{Binding Path=WorkItem.Title}" Foreground="{DynamicResource FontColor}"></TextBlock>
                    </StackPanel>
                </DockPanel>
                
            </Border>
        </DataTemplate>

    </UserControl.Resources>
    <UserControl.CommandBindings>
        <!--<CommandBinding Command="local:HeatList.UpdateCallLogCommand" Executed="UpdateCallLogCommand_Executed"/>-->
    </UserControl.CommandBindings>
    
    <Border Width="Auto" Padding="5,0,5,0" Opacity="0.8" x:Name="Header" Background="Transparent" Style="{DynamicResource BorderStyle}" BorderThickness="0" CornerRadius="5,5,0,0" HorizontalAlignment="Stretch">
        <!--Setup menu command bindings-->
                        <ListView ItemsSource="{Binding Items}" Background="Transparent" Height="Auto" BorderBrush="Transparent" Name="ListBox1" Width="Auto" Style="{DynamicResource HeatListViewStyle}" ItemContainerStyle="{DynamicResource HeatListViewItemStyle}">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Heat ITSM" Width="Auto" CellTemplate="{DynamicResource CallLogTemplate}" HeaderContainerStyle="{DynamicResource FirstColumnGridViewColumnHeader}" />
                    <GridViewColumn Header="TFS" Width="Auto" CellTemplate="{DynamicResource WorkItemTemplate}" HeaderContainerStyle="{DynamicResource FirstColumnGridViewColumnHeader}" />
                </GridView>
            </ListView.View>
        </ListView>  
      
    </Border>
</UserControl>
